package com.ysd.twocrm.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import javax.servlet.Filter;

@Configuration
public class CrossConfig extends WebMvcConfigurerAdapter {

    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE","OPTIONS")
                .allowCredentials(true).maxAge(3600);
    }



     @Override
    public void addInterceptors(InterceptorRegistry registry){

         String[] parttens=new String[]{"/users/**","/*.html","/poiStudent","/websocket/**","/orders","/orders/*","/aliyun/getSsm"};

        registry.addInterceptor(new SysInterceptor())
                .addPathPatterns("/**").excludePathPatterns(parttens);

        super.addInterceptors(registry);

    }




}
